package com.dh.cheesestrip.HttpUtil.callback;


import com.dh.cheesestrip.HttpUtil.HttpResObj;

import java.io.IOException;

import okhttp3.Request;
import okhttp3.Response;

public abstract class HttpCallback<T> {


    /**
     * UI Thread
     *
     */
    public void onBefore() {

    }

    /**
     * UI Thread
     *
     * @param
     */
    public void onAfter() {

    }

    /**
     * UI Thread
     *
     * @param progress
     */
    public void inProgress(float progress) {

    }

    /**
     * Thread Pool Thread
     *
     * @param resObj
     */
    public abstract T parseNetworkResponse(HttpResObj resObj) throws IOException, Exception;
    public abstract T parseNetworkResponse(Response response) throws IOException, Exception;

    public abstract void onError(Request request, Exception e);

    public abstract void onResponse(T response);
    public abstract void onFailure(HttpResObj resObj);


    public static HttpCallback CALLBACK_DEFAULT = new HttpCallback() {


        @Override
        public Object parseNetworkResponse(HttpResObj resObj) throws IOException {

            return null;
        }

        @Override
        public Object parseNetworkResponse(Response resObj) throws IOException, Exception {
            return null;
        }

        @Override
        public void onError(Request request, Exception e) {

        }

        @Override
        public void onResponse(Object response) {

        }

        @Override
        public void onFailure(HttpResObj resObj) {

        }

    };

}